package com.wanwu.channel.remote.biz.impl;


import com.wanli.clear.facade.ClearPayFacade;
import com.wanli.clear.facade.dto.req.ClearNotifyReqDto;
import com.wanli.clear.facade.dto.resp.ClearNotifyRespDto;
import com.wanwu.channel.common.enums.ExceptionEnum;
import com.wanwu.channel.common.exception.SystemException;
import com.wanwu.channel.common.util.LogUtil;
import com.wanwu.channel.remote.biz.ClearRemoteBiz;
import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.config.annotation.Reference;
import org.springframework.stereotype.Service;

/**
 * @author JiWen
 * @time 2020/3/19 21:07
 */
@Service("clearRemoteFacade")
@Slf4j
public class ClearRemoteBizImpl implements ClearRemoteBiz {

    @Reference(group = "clear", version = "1.0.0", check = false)
    private ClearPayFacade clearPayFacade;

    @Override
    public ClearNotifyRespDto notifyResult(ClearNotifyReqDto reqDto) {
        LogUtil.info(log, "渠道回调清分入参 reqDto: {0}", reqDto);
        long start = System.currentTimeMillis();
        try {
            ClearNotifyRespDto respDto = clearPayFacade.notifyResult(reqDto);
            long cost = System.currentTimeMillis() - start;
            LogUtil.info(log, "渠道回调清分返回 respDto: {0}, 耗时{1}ms", respDto, cost);
            return respDto;
        } catch (Exception e) {
            LogUtil.error(log, e, "渠道回调清分异常 reqDto:{0}", reqDto);
            throw new SystemException(ExceptionEnum.E10059);
        }
    }
}
